/*
 * Created on Jul 5, 2005
 *
 */
package com.erclab.internal.xpresso.formelements;

import com.erclab.internal.xpresso.forms.Form;

/**
 * @author Enrique Rodriguez.
 *
 */
public class SimpleCurrencyBox extends SimpleInputBox {

	

	/* (non-Javadoc)
	 * @see com.erclab.internal.xpresso.formelements.FormElement#toHTML(com.erclab.internal.xpresso.forms.Form)
	 */
	public String toHTML(Form theForm) {
		StringBuffer sb = new StringBuffer(super.toHTML(theForm));
		int endOfTag = sb.indexOf("onChange=");
		
		return sb.substring(0, endOfTag) + 
					" onKeypress=\"if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;\"" +
					// TODO: Add a client script to format the currency and
					// override the processSubmitted values to transform it to number
					// " onChange=\"this.value=formatTextToCurrency(this.value);formElementChanged(this)\">";
					" onChange=\"formElementChanged(this)\">";
	}

}
